package cn.z2huo.knowledge.deepunderstandjvm.clinit;

/**
 * <p>
 *
 * @author z2huo
 */
class ClinitBlockTest {

    static {
        if (true) {
            // 不加这个 if 判断会报如下的编译错误并拒绝编译
            // Initializer must be able to complete normally
            System.out.println(Thread.currentThread() + " init");
            while (true) {
            }
        }
    }

    public static void main(String[] args) {
        Runnable runnable = () -> {
            System.out.println(Thread.currentThread() + "start");
            ClinitBlockTest clinitBlockTest = new ClinitBlockTest();
            System.out.println(Thread.currentThread() + " end");
        };

        Thread thread = new Thread(runnable);
        Thread thread2 = new Thread(runnable);

        thread.start();
        thread2.start();
    }

}
